﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace Hyunhdai_Saigon_Project
{
    public partial class admin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
       
        {     if (Session["TenDangNhap"] == null || Session["MatKhau"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else
            {
                try
                {
                    if (!Request.QueryString["nsx"].Equals("1"))
                    {
                        string s = getNameOfID(Request.QueryString["nsx"]);
                       // tuade.Text = "Các dòng xe " + s;
                    }
                    else
                     //   tuade.Text = "Tất cả các dòng xe";
                }
                catch (Exception)
                {
                 //   tuade.Text = "Tất cả các dòng xe";
                }
            }
        }
        protected void DangXuat_Click(object sender, EventArgs e)
        {
            Session.RemoveAll();
            Response.Redirect("Default.aspx");
        }
        protected void ThemSp_Click(object sender, EventArgs e)
        {
            Response.Redirect("Them-San-Pham.aspx");
        }
        protected void ThemBv_Click(object sender, EventArgs e)
        {
            Response.Redirect("Viet-Bai.aspx");
        }
        protected void QLBaiViet_Click(object sender, EventArgs e)
        {
            Response.Redirect("Quan-Ly-Bai-Viet.aspx");
        }

        protected void ThemHX_Click(object sender, EventArgs e)
        {
            Response.Redirect("Quan-Li-Hang-Xe.aspx");
        }
        protected string getNameOfID(string nsx)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["hyundaisaigonConnectionString"].ConnectionString);
            connection.Open();

            string sql = "select name from nhasanxuat where id = " + nsx;

            SqlDataAdapter da = new SqlDataAdapter(sql, connection);
            DataTable dt = new DataTable();
            da.Fill(dt);
            string arr = dt.Rows[0][0].ToString();
            return arr;
        }


    }
}